<template>
	<view>
		<view class="plr14 bgWhite ">
			<view class="justify-between bdbe ptb8 align-center">
				<view class="ft16 gray3"><text>{{$t('set').头像}}</text></view>
				<image class="radius50" :src="userInfo.avatar" mode="aspectFill" style="width: 94rpx;height: 94rpx;">
				</image>
			</view>
			<view class="justify-between bdbe ptb15 align-center">
				<view class="ft16 gray3"><text>{{$t('set').昵称}}</text></view>
				<view class="ft16 gray3"><text>{{userInfo.nickname}}</text></view>
			</view>
			<view class="justify-between  ptb15 align-center">
				<view class="ft16 gray3"><text>{{$t('set').登录账号}}</text></view>
				<view class="ft16 gray3"><text>{{userInfo.phone}}</text></view>
			</view>
		</view>
		<view class="bgWhite plr14   mt10">
			<view class="align-center justify-between ptb15 bdbe" @click="navTo('/pages/setting/setPassword')">
				<view class="ft16 gray3"><text>{{$t('set').支付密码}}</text></view>
				<view class=" align-center">
					<view v-if="!userInfo.pay_password" class="ft14 mr10 light"><text>{{$t('set').去设置}}</text></view>
					<view v-else class="ft14 mr10 gray3"><text>{{$t('set').已设置}}</text></view>
					<image src="../../static/images/mine/icon/arrowright.png" mode="aspectFill"
						style="width: 10rpx;height: 18rpx;"></image>
				</view>
			</view>
			<view class="align-center justify-between ptb15" @click="navTo('/pages/setting/setArea')">
				<view class="ft16 gray3"><text>{{$t('set').区域设置}}</text></view>
				<view class=" align-center">
					<view class="ft14 mr10 light"><text>{{userInfo.area==2?$t('set').港澳区域:$t('set').中国大陆}}</text></view>
					<image src="../../static/images/mine/icon/arrowright.png" mode="aspectFill"
						style="width: 10rpx;height: 18rpx;"></image>
				</view>

			</view>
		</view>
		<view class="plr14 bgWhite mt10">
			<view class="  align-center justify-between ptb15 bdbe" @click="coinshow=true" v-if="userInfo.area==2">
				<view class="ft16 gray3"><text>{{$t('set').币种显示}}</text></view>
				<view class=" align-center">
					<view class="ft14 mr10 gray3"><text>{{cointype==0?$t('index').美元:$t('set').人民币}}</text></view>
					<image src="../../static/images/mine/icon/arrowright.png" mode="aspectFill"
						style="width: 10rpx;height: 18rpx;"></image>
				</view>
			</view>
			<view class="  align-center justify-between ptb15 " @click="navTo('/pages/setting/setLanguage')" v-if="userInfo.area==2">
				<view class="ft16 gray3"><text>{{$t('set').语言}}</text></view>
				<view class=" align-center">
					<view class="ft14 mr10 gray3"><text>{{language.title}}</text></view>
					<image src="../../static/images/mine/icon/arrowright.png" mode="aspectFill"
						style="width: 10rpx;height: 18rpx;"></image>
				</view>
			</view>
		</view>
		<view class="ft16 tc bgWhite mt10 ptb15" style="color: #F23C4B;" @click="outlogin()">
			<text>{{$t('set').退出登录}}</text>
		</view>
		<!-- 是否设置密码弹窗 -->
		<view>
			<u-modal :showCancelButton="true" :confirmText="$t('set').立即设置" confirmColor="#F44A42" cancelColor="#333333"
				:cancelText="$t('common').取消" width="600rpx" :show="show" :content="$t('set').您还未设置支付密码是否立即设置"
				:closeOnClickOverlay="closeOnClickOverlay" @cancel="cancel()" @close="cancel()"
				@confirm="confirm()"></u-modal>
		</view>
		<!-- 是否设置币种弹窗 -->
		<view>
			<u-modal :showCancelButton="true" :confirmText="$t('common').确认" confirmColor="#F44A42"
				cancelColor="#333333" :cancelText="$t('common').取消" width="600rpx" :show="coinshow"
				:closeOnClickOverlay="closeOnClickOverlay" @cancel="cancel()" @close="cancel()" @confirm="confirmcoin()"
				:title="$t('index').修改显示币种">
				<view class="w100 ft16 gray3">
					<text>{{$t('set').当前币种}}：{{cointype==0?$t('index').美元:$t('set').人民币}}，{{$t('set').确定修改币种为}}{{cointype==0?$t('set').人民币:$t('index').美元}}{{$t('set').吗修改后您的账户信息及收益信息将按}}{{cointype==0?$t('set').人民币:$t('index').美元}}{{$t('set').金额显示您可再次修改}}</text>
				</view>
			</u-modal>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				closeOnClickOverlay: true,
				coinshow: false,
				cointype: uni.getStorageSync('currency') == 'CNY' ? 1 : 0,
				language: uni.getStorageSync('lang'),

			}
		},
		onLoad() {
			// this.$store.dispatch('getuserInfo')
			this.language = uni.getStorageSync('lang')
		},
		onShow() {
			this.cointype = uni.getStorageSync('currency') == 'CNY' ? 1 : 0,
			this.$store.dispatch('getuserInfo')
			this.language = uni.getStorageSync('lang')
			uni.setNavigationBarTitle({
				title: this.$t('set').设置
			})
		},
		computed: {
			userInfo() {
				return this.$store.state.userInfo
			}
		},
		// watch: {
		// 	userInfo: {
		// 		handler(nVal, oVal) {
		// 			if (this.userInfo.pay_password == null) {
		// 				this.show = true
		// 			} else {
		// 				this.show = false
		// 			}
		// 		}
		// 	}
		// },
		methods: {
			cancel() {
				this.show = false
				this.coinshow = false
			},
			confirm() {
				this.show = false
				this.navTo('/pages/setting/setPassword')
			},
			confirmcoin() {
				if (this.cointype == 0) {
					this.cointype = 1
					this.coinshow = false
					uni.setStorageSync('currency', 'CNY')
					this.$store.commit("saveCurrency", 'CNY')
					return;
				}
				if (this.cointype == 1) {
					this.cointype = 0
					this.coinshow = false
					uni.setStorageSync('currency', 'USD')
					this.$store.commit("saveCurrency", 'USD')
					return;
				}
			},
			outlogin() {
				uni.removeStorageSync('logintoken')
				uni.removeStorageSync('currency')
				uni.removeStorageSync('rate')
				uni.removeStorageSync('lang')
				uni.removeStorageSync('userInfo')
				uni.removeStorageSync('bingCardInfo')
				uni.removeStorageSync('HTBingCardInfo')
				uni.removeStorageSync('ztfsObj')
				this.navTo('/pages/login/login')
			}
		}
	}
</script>

<style>
	/deep/.u-modal__content__text {
		color: #333333;

	}

	/deep/.u-modal__title {
		color: #333333;
	}
</style>